package com.lc202309;

import java.util.ArrayList;
import java.util.List;

/**
 * Description:
 *
 * @Create 2023/9/6 20:00
 * @Version 1.0
 */
public class Solution1023 {
    public static List<Boolean> camelMatch(String[] queries, String pattern) {
        List<Boolean> res = new ArrayList<>();
        int num2 = 0;
        int pLength = pattern.length();
        for (int i = 0; i < pLength; i++) {
            if (pattern.charAt(i) <= 'Z') {
                num2++;
            }
        }
        int size, num1;
        for (String query : queries) {
            size = 0;
            num1 = 0;
            for (int i = 0; i < query.length(); i++) {
                if (size < pLength && query.charAt(i) == pattern.charAt(size)) {
                    size += 1;
                }
                if (query.charAt(i) <= 'Z') {
                    num1++;
                }
            }
            if (size < pLength) {
                res.add(false);
                continue;
            }
            if (size == pLength && num1 == num2) {
                res.add(true);
                continue;
            }
            res.add(false);
        }
        return res;
    }

    public List<Boolean> camelMatch1(String[] queries, String pattern) {
        List<Boolean> res = new ArrayList<>();
        int num2 = 0;
        int pLength = pattern.length();
        for (int i = 0; i < pLength; i++) {
            if (pattern.charAt(i) <= 'Z') {
                num2++;
            }
        }
        for (int j = 0; j < queries.length; j++) {
            int size = 0;
            int num1 = 0;
            for (int i = 0; i < queries[j].length(); i++) {
                if (size < pLength) {
                    if (queries[j].charAt(i) == pattern.charAt(size)) {
                        size += 1;
                    }
                }
                if (queries[j].charAt(i) <= 'Z') {
                    num1++;
                }
            }
            if (size == pLength && num1 == num2) {
                res.add(true);
                continue;
            }
            res.add(false);
        }
        return res;
    }

    public static void main(String[] args) {
        /*System.out.println((int) 'A');
        System.out.println((int) 'a');
        System.out.println((int) 'z');
        System.out.println((int) 'Z');*/
        String[] queries = {"FooBar", "FooBarTest", "FootBall", "FrameBuffer", "ForceFeedBack"};
        String pattern = "FB";
        System.out.println(camelMatch(queries, pattern));
    }
}
